package com.study.hospital_3.controller;

import com.study.hospital_3.service.DrugService;
import com.study.hospital_3.vo.DrugUpdateVO;
import com.study.hospital_3.vo.DrugVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

    @RestController
    @Api(value = "用户数据测试",tags = "用户数据接口API")
    @RequestMapping("/drug")
    public class DrugController {

        @Resource
        private DrugService drugService;

        public Map<String, Object> selectNull() {
            return drugService.selectDrugs(null);
        }
        @GetMapping("/selectDrugs")
        @ApiOperation(value = "用户查询列表接口 get",notes = "用户查询列表接口 get",httpMethod = "GET", response = String.class)
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public Map<String, Object> selectDrugs(DrugVO drugVO) {
            return drugService.selectDrugs(drugVO);
        }

        @PostMapping("/insert")
        public Map<String, Object> insert(@RequestBody DrugVO drugVO) {
            return drugService.insert(drugVO);
        }


        @PostMapping("/deleteById")
        public Map<String, Object> deleteById(@RequestParam Integer id) {
            return drugService.deleteById(id);
        }

        @PostMapping("/updateById")
        public Map<String, Object> updateById(@RequestBody DrugUpdateVO drugUpdateVO) {
            return drugService.updateById(drugUpdateVO);
        }
}
